package com.kkb.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

// /default/gotoResult.do
@Controller
@RequestMapping("/default")
public class DefaultController {
    @RequestMapping("/gotoResult")
    public ModelAndView gotoResult(ModelAndView modelAndView){
        modelAndView.addObject("name","琉璃");
        modelAndView.addObject("desc","DefaultController的RequestMapping注解");
        modelAndView.setViewName("result");
        return modelAndView;
    }

    @GetMapping("/gotoResultMethod")
    public ModelAndView gotoResultGet(ModelAndView modelAndView){
        modelAndView.addObject("name","琉璃");
        modelAndView.addObject("desc","DefaultController的GetMapping注解");
        modelAndView.setViewName("result");
        return modelAndView;
    }

    @PostMapping("/gotoResultMethod")
    public ModelAndView gotoResultPost(ModelAndView modelAndView){
        modelAndView.addObject("name","琉璃");
        modelAndView.addObject("desc","DefaultController的PostMapping注解");
        modelAndView.setViewName("result");
        return modelAndView;
    }
}
